/**
 * @file 全局布置
 * @author 叶永鸿
 * @description 在全局引用功能组件
 * @date 2021-7-11
 * @LastEditors 叶永鸿
 * @LastEditTime 2021-7-28
 */
import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementPlus from 'element-plus';
import 'element-plus/lib/theme-chalk/index.css'
import axios from 'axios'
import qs from 'qs'

import { ElMessage } from "element-plus";



axios.interceptors.request.use(function(config){
  store.state.loadding=true; 
  return config
})

axios.interceptors.response.use(function(config){
  //console.log(config)
  if(config.data.message=='Invalid Token'){
    ElMessage({
      message: "用户信息已过期，请重新登陆",
      type: "error",
    });
    store.commit("login", {
      userName: "",
      station: 0,
      token: "",
    });
    router.push("/login");
  }
  return config
})


const app = createApp(App)
app.config.globalProperties.$axios = axios
app.config.globalProperties.$router = router
app.use(store)
app.use(router)
app.use(ElementPlus)
app.mount('#app')
